<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>详细内容</title>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap-datetimepicker.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/common.css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/picker.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/loading.css" type="text/css">
   	<%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
   	<script src="${assets}/bootstrapValidator/js/bootstrapValidator.js"></script>
   	<script src="${assets}/bootstrapValidator/js/language/zh_CN.js"></script>
   	<script src="${newframe}/js/ajaxfileupload.js"></script>
   	<script>
   	$(document).ready(function() {
   		$('#myForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                repairType: {
                    validators: {
                    	notEmpty: true
                    }
                },
                repairTime: {
                    validators: {
                    	notEmpty: true
                    }
                }
            }
        }).on('success.form.bv', function (e) {
            e.preventDefault();
            $("#loading").css("display","block");
             $.ajax({
                url:'${URL_QULITITY_UPDATEREPAIR}',
                type:'post',
                data:$('#myForm').serialize(),
                async : false, //默认为true 异步
                error:function(){
                    alert('error');
                },
                success:function(data){
                	uploadFile(data.msg);
                	
                }
            }); 
        });
   		
   		initDateTime("#TimeArea");	
   	});
   	
   	//关闭并刷新
	function closeFrame(){
		window.parent.table.ajax.reload(null);
		window.parent.closeModal();
	}
	function initDateTime(id){
        var t = $(id).datetimepicker({
            language:  'zh-CN',
            weekStart:  0,
            todayBtn: true,
            autoclose:  1,
            todayHighlight: 1,
            startView: 2,
            minView: 2,
            forceParse: 0
        });
    }
	function uploadFile(id){
		$.ajaxFileUpload({
                url: '${URL_QULITITY_UPLOADREPAIRIMG}', //用于文件上传的服务器端请求地址
                secureuri: false, //是否需要安全协议，一般设置为false
                fileElementId: 'files', //文件上传域的ID
               /*  dataType: 'json', //返回值类型 一般设置为json */
                data:{id:id},
                success: function (data, status)  //服务器成功响应处理函数
                {	
                	if(data.body.innerText == 'success'){
                		$("#loading").css("display","none");
                		closeFrame();
                	}else{
                		$("#loading").css("display","none");
                		alert(data.error);
                	}
                	/* if(data.success){
                		
                		
                	}else{
                		
                	} */
                },
                error: function (data, status, e)//服务器响应失败处理函数
                {
                	$("#loading").css("display","none");
                    alert("上传图片失败，请重新上传！");
                }
         });
	}
   	</script>
</head>
<body style="width: 98%">
<form id="myForm" class="form-horizontal" method="post" >
    <input type="hidden" id="id" name="id" value="${entity.id}" />
    <input type="hidden" id="instrumentId" name="instrumentId" value="${entity.instrumentId}" />
    <div class="clearfix">
    	<div class="form-group col-sm-6">
	        <label class="col-sm-4 control-label">维修日期</label>
	        <div class="col-sm-8">
		        <div id="TimeArea" class="input-group date form_date" style="width: 100%" data-date-format="yyyy-mm-dd">
	                <input id="repairTime" name="repairTime" value="${entity.repairTime}" class="form-control" type="text" readonly style="text-indent:0">
	                <span class="input-group-addon">
	                    <span class="glyphicon-calendar">&gt;</span>
	                </span>
	            </div>
	        </div>
	    </div>
	    <div class="form-group col-sm-6">
	    	<label class="col-sm-4 control-label">维修人</label>
	        <div class="col-sm-8">
	            <input type="text" id="repairMan" name="repairMan" value="${entity.repairMan}" class="form-control" >
	        </div>
	    </div>
	   <div class="form-group col-sm-6">
	        <label for="repairType" class="col-sm-4 control-label" id="">故障类别</label>
	        <div class="col-sm-8">
	            <select id="repairType" name="repairType" class="form-control">
	                <option value="">请选择...</option>
	                <option value="001" <c:if test="${entity.repairType==001}">selected="selected"</c:if>>操作不当</option>
	                <option value="002" <c:if test="${entity.repairType==002}">selected="selected"</c:if>>开关机异常</option>
	                <option value="003" <c:if test="${entity.repairType==003}">selected="selected"</c:if>>充值异常</option>
	                <option value="004" <c:if test="${entity.repairType==004}">selected="selected"</c:if>>屏幕异常</option>
	                <option value="005" <c:if test="${entity.repairType==005}">selected="selected"</c:if>>开关门异常</option>
	                <option value="006" <c:if test="${entity.repairType==006}">selected="selected"</c:if>>温度异常</option>
	                <option value="007" <c:if test="${entity.repairType==007}">selected="selected"</c:if>>样本测试异常</option>
	                <option value="008" <c:if test="${entity.repairType==008}">selected="selected"</c:if>>质控测试异常</option>
	                <option value="009" <c:if test="${entity.repairType==009}">selected="selected"</c:if>>试剂异常</option>
	            </select>
	        </div>
    	</div>
    	
 		<div class="form-group col-sm-6">
	        <label class="col-sm-4 control-label">图片</label>
	        <div class="col-sm-8">
	            <input type="file" name="files" id="files" multiple="multiple" class="form-control" style="border:none;"/>
	        </div>
	    </div>	    

	 <!--  <div class="clearfix">  --> 
	    <div class="form-group col-sm-6">
	        <label class="col-sm-4 control-label">维修描述</label>
	        <div class="col-sm-8">
	            <textarea id="repairDesc" name="repairDesc" class="form-control" rows="5" >${entity.repairDesc}
	            </textarea>
	        </div>
	    </div>
	</div>
    <div class="modal-footer" style="text-align: center ">
        <button type="button" class="btn btn-default" data-dismiss="modal" id="closeModalButt" onclick="closeFrame()">关闭</button>
        <button type="submit" class="btn btn-primary">保存</button>
    </div>
</form>
<div id="loading" class="loading" style="display:none">正在全力保存中...</div> 
</body>
</html>